//
//  CalculationController.m
//  AntsExpress
//
//  Created by slccper on 16/1/8.
//  Copyright © 2016年 slccper. All rights reserved.
//

#import "CalculationController.h"
#import "CalculaViewCell.h"
#import "CalculationNextController.h"

@interface CalculationController ()<UITableViewDataSource,UITableViewDelegate>
{
    NSMutableArray *dataList;
}
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation CalculationController

- (void)viewDidLoad {
    [super viewDidLoad];
//    dataList = [NSMutableArray array];
//    [dataList addObjectsFromArray:@[@"珠海",@"澳門",@"氹仔"]];
    self.tableView.sectionHeaderHeight=40;
    self.tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
    self.tableView.tableFooterView=[[UIView alloc]init];
    self.title = @"取貨點查詢";
    // Do any additional setup after loading the view from its nib.
}
-(void)getWebData
{
    if ([clsOtherFun CheckNetworkStatus:YES]) {
        [clsOtherFun showLoadingView:@"正在獲取數據..."];
        if (ants) {
            ants.delegate=nil;
            ants=nil;
        }
        ants = [[clsAntsService alloc]init];
        ants.delegate=self;
        [ants GetPickUpPoint:@""];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - UITableView
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return dataList.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"CalculaViewCell";
    
    CalculaViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle]loadNibNamed:@"CalculaViewCell" owner:self options:nil]lastObject];
        cell.accessoryType = UITableViewCellAccessoryNone;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.parentViewController=self;
    }
    NSDictionary *dic = [dataList objectAtIndex:indexPath.section];
    //    cell.imageView.image=[clsOtherFun createImageWithColor:[UIColor blueColor]];
    [cell setDataWith:dic];
    return cell;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    return [[UIView alloc]init];
}
-(void)getAntsDataFail:(NSInteger)type
{
    [clsOtherFun hideLoadingView];
}
-(void)getAntsDataSuccess:(NSInteger)type :(NSMutableDictionary *)pDictionary
{
    [clsOtherFun hideLoadingView];
    NSDictionary *dic = [pDictionary objectForKey:@"data"];
    dataList = [dic objectForKey:@"data"];
    [self.tableView reloadData];
}
@end
